package com.fileServer.config;

import com.fileServer.fileHandler.CustomFileHandlerMapping;
import com.fileServer.fileHandler.CustomFileResourceHttpRequestHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * @author 大忽悠
 * @create 2023/2/28 10:46
 */
@Configuration
public class CustomMvcConfig {

    @Bean
    public CustomFileHandlerMapping customFileHandlerMapping(CustomFileResourceHttpRequestHandler customFileResourceHttpRequestHandler){
        return new CustomFileHandlerMapping(customFileResourceHttpRequestHandler);
    }

    @Bean
    public CustomFileResourceHttpRequestHandler customFileResourceHttpRequestHandler(OssProperties ossProperties){
        CustomFileResourceHttpRequestHandler requestHandler = new CustomFileResourceHttpRequestHandler();
        requestHandler.setLocationValues(List.of("file:"+ossProperties.getRootPath()));
        return requestHandler;
    }
}
